#include <bits/stdc++.h>

using namespace std;
const int N = 1000 + 10;
typedef long long ll;

vector<int> adj1[N], adj2[N];
vector<int> dis1, dis2;
bool nm[N * 2];
bool vis[N][N];
int n1, n2, m1, m2;

void dfs(vector<int> &dis, int n, vector<int> (&adj)[N], int u, int dep) {
  if (u == n) dis.push_back(dep);
  for (int v : adj[u]) {
    if (!vis[v][dep + 1]) {
      vis[v][dep + 1] = true;
      dfs(dis, n, adj, v, dep + 1);
    }
  }
}

int main() {
  cin >> n1 >> n2 >> m1 >> m2;
  for (int i = 1; i <= m1; i++) {
    int x, y;
    cin >> x >> y;
    adj1[x].push_back(y);
  }
  for (int i = 1; i <= m2; i++) {
    int x, y;
    cin >> x >> y;
    adj2[x].push_back(y);
  }
  dfs(dis1, n1, adj1, 1, 0);
  memset(vis, 0, sizeof(vis));
  dfs(dis2, n2, adj2, 1, 0);
  for (int x : dis1) {
    for (int y : dis2) {
      nm[x + y] = true;
    }
  }
  int k, q;
  cin >> k;
  while (k--) {
    cin >> q;
    cout << (nm[q] ? "YES\n" : "NO\n");
  }
  return 0;
}
